<?php
include_once("./_common.php");
include_once("./admin.head.php");
/*
$flag
지역 a_area
계약일 a_firstday
개설일 a_openday
100일전 통보일 a_notiday
*/
if (!$sst) {
    $sst = "id";
    $sod = "asc";
}

$sql_order = " order by $sst $sod ";

$sql = "SELECT	*
		FROM	manage
		$sql_order";
$rst = sql_query($sql);
while($row = mysql_fetch_assoc($rst)) {
	$list[] = $row;
}



if($sst == "id") {
	$to_day = date("Y-m-d");

	$sql2 = "select id from manage where a_notiday = '$to_day' AND a_noti = '1'";
	$rst2 = sql_query($sql2);
	while($row2 = mysql_fetch_assoc($rst2)) {
		$list2[] = $row2;
	}//print_r2($list2);
	for($i = 0; $i < count($list2); $i += 1) {
		$left = $i * 50;
		$top = ($i + 1) * 50;
	?>
		<script>
			window.open("./manage_main_pop.php?idx=<?php echo $list2[$i][id]?>" ,"100일전 통보<?php echo $list2[$i][id]?>","width=500px,height=500px,left=<?php echo $left?>,top=<?php echo $top?>,menubar=no,toolbar=no,location=no,scrollbars=no,status=no");
		</script>
	<?php
	}
}
?>

<style>


div.aff_top {overflow:hidden;margin-bottom:15px;}
div.aff_insert {float:left}
div.aff_main {float:left}
div.aff_search {float:right}
div.aff_table {}
table.aff_info {width:1024px;}
table.aff_info tr {line-height:24px;}
table.aff_info th {background:url(/test/manage/imgs/tit_bg.gif) repeat-x;height:38px;color:white;line-height:16px;font-weight:normal;}
table.aff_info th a {color:white;font-weight:bold}
table.aff_info td {text-align:center;height:30px;}
table.aff_info td a {color:black;}

</style>
<link rel="stylesheet" href="<?php echo $g4['path']?>/css/jquery-ui.css" />
<script src="<?php echo $g4['path']?>/js/jquery-1.9.1.js"></script>
<script src="<?php echo $g4['path']?>/js/jquery-ui.js"></script>
<script>

$(function() {
	$( "#datepicker" ).datepicker({
	  showOn: "button",
	  buttonImage: "/test/img/calendar.gif",
	  buttonImageOnly: true,
	  showAnim: "slideDown",
	  dateFormat: "yy-mm-dd",
	  changeMonth: true,
	  changeYear: true,
	  monthNames: true
	});
});
</script>


<div style="text-align:center">
	<br />
	<img src="<?php echo $g4['path']?>/test/manage/imgs/manage_tit.jpg" style="display:block;width:185px;margin:0 auto;text-align:center"/>
	<div class="aff_wrap">
		<div class="aff_top">
			<div class="aff_insert">
				<img src="<?php echo $g4['path']?>/test/manage/imgs/insert_btn.gif" class="btn_insert" style="cursor:pointer;vertical-align:bottom" />
			</div>
			<div class="aff_main">
				<input type="button" value="main" class="main_bt" />
			</div>
			<div class="aff_search">
				<select name="" class="sfl">
				<option value="">검색조건선택</option>
				<option value="a_area">지역</option>
				<option value="a_name1">가맹점명</option>
				</select>
				<input type="text" name="" class="stx" value="" />
				<img src="<?php echo $g4['path']?>/test/manage/imgs/search_btn.gif" class="sbt" style="cursor:pointer;vertical-align:bottom" />
			</div>
		</div>
		<script>
		$(".sbt").click(function() {
			var sfl = $(".sfl").val();
			var stx = $(".stx").val();
			if(sfl != "" && stx != "") {
				$.ajax({
					type : "POST",
					url : "./ajax_manage.php",
					data : {
						a : sfl,
						b : stx
					},
					success : function(data){
							$(".aff_table").html(data);
							$(".main_bt").show();
					},
					dataType : "html"
				});
			} else {
				alert("검색오류");
			}
		});
		</script>
		<div class="aff_table">
			<table class="board_list" cellpadding="0" cellspacing="0" border="0">
			<col width="70"/>
		    <col width="100" />
		    <col width="100" />
		    <col width="170"/>
	     	<col width="100"/>
			<col width="150"/>
	       	<col width="100"/>
			<col width="100"/>
			<col width="100"/>
			<tr >
				<th><?=subject_sort_link('a_area')?>지역</a></th>
				<th><?=subject_sort_link('a_firstday')?>계약일</a></th>
				<th><?=subject_sort_link('a_openday')?>개설일</a></th>
				<th>가맹점명</th>
				<th>점주명</th>
				<th>사업자번호</th>
				<th>매장전화</th>
				<!-- <th>핸드폰번호</th>-->
				<th>계약만료일</th>
				<!-- <th><?=subject_sort_link('a_notiday')?>100일전<br />통보일</a></th>-->
				<th>양도양수<br />여부</th>
			</tr>
		
			<?php
			for($i = 0; $i < count($list); $i += 1) {
				$bg = $i%2 ? 0 : 1;
			?>
			<?php
			if($to_day == $list[$i]['a_notiday']) {
				if($list[$i]['a_noti'] == "2") {
					echo "<tr style='color:#ff4040'>";
				} else if ($list[$i]['a_noti'] == "3") {
					echo "<tr style='background-color:#ff4040'>";
				} else if ($list[$i]['a_noti'] == "1") {
					echo "<tr>";
				}
			}
			?>
			<tr class="bg<?=$bg?>">
			<td><?php echo $list[$i]['a_area']?></td>
			<td><?php echo $list[$i]['a_firstday']?></td>
			<td><?php echo $list[$i]['a_openday']?></td>
			<td><a href="./manage_view.php?bo_table=manage&id=<?php echo $list[$i]['id']?>"><?php echo $list[$i]['a_name1']?></a></td>
			<td><?php echo $list[$i]['a_name2']?></td>
			<td><?php echo $list[$i]['a_num1']." - ".$list[$i]['a_num2']." - ".$list[$i]['a_num3']?></td>
			<td><?php echo $list[$i]['a_tel']?></td>
			<!-- <td><?php echo $list[$i]['a_hp']?></td>-->
			<!-- <td><?php echo $list[$i]['a_endday']?></td>-->
			<td><?php echo $list[$i]['a_notiday']?></td>
			<td>
				<?php
				if($list[$i]['a_transfer'] == "1") {
					echo "여";
				} else if($list[$i]['a_transfer'] == "2") {
					echo "부";
				}
				?>
			</td>
			
			</tr>
			
			<? } ?>
			</table>
		</div>
	</div>
</div>
<script>
window.onload = function() {
	$(".main_bt").hide();
};

function m_pop(a) {
	window.open("./manage_pop.php?idx=" + a,"기타내용","width=300px,height=300px,menubar=no,toolbar=no,location=no,scrollbars=no,status=no");
}

$(".main_bt").click(function() {
	location.href = "./manage.php?bo_table=manage";
});

$(".btn_insert").click(function() {
	location.href = "./manage_insert.php?bo_table=manage";
});
</script>
<?
include_once ("../admin.tail.php");
?>